home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: artemis.sto.fdata.se!news
- From: Niklas Mellin <niklas.mellin@sto.fdata.se>
- Subject: Re: Default Class Initialisation Question...
- Sender: news@artemis.sto.fdata.se (UseNet NetNews)
- Message-ID: <3156D1BF.36E9@sto.fdata.se>
- Date: Mon, 25 Mar 1996 17:02:55 GMT
- Content-Transfer-Encoding: 7bit
- Content-Type: text/plain; charset=us-ascii
- References: <00001a81+0000af6f@msn.com> <4j57mv$6ps@park.interport.net>
- Mime-Version: 1.0
- X-Mailer: Mozilla 2.0 (WinNT; I)
- Organization: WM-data F÷rsvarsdata AB, Sweden
-
- Adi wrote:
- >
- > Tony_Bateman@msn.com (Tony Bateman) wrote:
- >
- > >I have a problem concerning default initialisation of classes.
- >
- > >If I define a class Rectangle, and have default initialisation values
- > >in the constructor defined thus:
- >
- > >Rectangle::Rectangle(USHORT width=0, USHORT height=0):
- > >itsWidth(width),
- > >itsHeight(height)
- > >{}
- >
- > >then I can define a rectangle to have a width = 30 and height = 0 by
- > >omitting one of the variables in the initialisation:
- >
- > >Rectangle myRectangle(30);
- >
- > >Fine. But what if I want to leave the width a default value of 0 and
- > >set the height to 30. How could I do it? Can it be done in C++ in a
- > >straightforward manner? Is there anything like a default placeholder
- > >that can be used?
- >
- > > Regards,
- > > Tony Bateman.
- >
- > >-----------------------------------------------------------------------------
- > >I live in Finland - second highest suicide rate per head of
- > >population in the world.
- > >It's the beginning of spring - most common time for suicides.
- > >Computer programmering is a recognised high risk suicide profession.
- > >Do NOT spill my pint.....
- > >-----------------------------------------------------------------------------
- > >
- >
- > Just forget about it. There is no such thing in the C++ syntax.
- > Annoying, ahha...
- >
- > Adi Degani
- > New-York, NY
-
- Bjarne Stroustrup mention this in his book: "The Design and Evolution of C++"
- and explains why it is done the way it is.
-
- ---
- Niklas Mellin
-